package com.herench.bs.handler;


import com.herench.bs.agent.IOutpatientClinicAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;


/**
 * Created by ThinkPad on 2017/8/27.
 */
@Component
@Handler(code = "102117",name="住院患者预交金缴纳查询")
public class DoPrePaymentsHandler_old extends AbstractMessageHandler {

    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        String idCard = requestMessage.getArgsPropertyStringValue("idNo");
        Assert.notNull(idCard, "idNo 不可为空！");
        String amount = requestMessage.getArgsPropertyStringValue("amount");
        Assert.notNull(amount, "amount 不可为空！");
        String tranNo = requestMessage.getArgsPropertyStringValue("tranNo");
        String moneyType = requestMessage.getArgsPropertyStringValue("moneyType");
        Assert.notNull(moneyType, "moneyType 不可为空！");
        String streamNo = requestMessage.getArgsPropertyStringValue("streamNo");

        String hospitalCode = getCleverClinicContext().getHospitalCodeByChannelCode(channelCode);
        IOutpatientClinicAgent outpatientClinicAgent = getCleverClinicContext().getApplicationContext().getBean(IOutpatientClinicAgent.class);
        Map<String, Object> resPatientId = outpatientClinicAgent.queryPatientInfo(channelCode, hospitalCode, idCard);
        String patientId = (String) resPatientId.get("patientId");

        Map<String, Object> res = outpatientClinicAgent.doPrePayments(channelCode, hospitalCode, idCard,patientId,amount,tranNo,moneyType,streamNo);
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage, res);
        return responseMessage;
    }
}
